<template>
  <div>
    <el-avatar :src="adminInfo.userInfo.avatar" />
    <span>{{ adminInfo.userInfo.name }}</span>

    <el-button @click="updateUserInfo()">更新1</el-button>
    <el-button @click="updateUserInfo2()">更新2</el-button>
    <el-button @click="goRouter()">goRouter</el-button>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { qiankunApp } from '@/qiankun/qiankun-app'
import { useAdminInfo } from '../../service/admin-info.service'

export default defineComponent({
  name: 'log',
  setup() {
    const { adminInfo } = useAdminInfo()
    const updateUserInfo = () => {
      adminInfo.value.userInfo.name = '李四'
    }
    const updateUserInfo2 = () => {
      qiankunApp.setState({
        userInfo: {
          ...adminInfo.value.userInfo,
          name: '王五',
        },
      })
    }
    const goRouter = () => {
      qiankunApp.action.goRouter('www.baidu.com')
    }

    return {
      adminInfo,
      updateUserInfo,
      updateUserInfo2,
      goRouter,
    }
  },
})
</script>
